package com.lw.cms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lw.cms.entity.CrmBanner;
import com.lw.cms.mapper.CrmMapper;
import com.lw.cms.service.CrmService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CrmServiceImpl extends ServiceImpl<CrmMapper, CrmBanner> implements CrmService {
    @Override
    @Cacheable( key = "'bannerList'",value = "banner")
    public List<CrmBanner> findTwoBanners() {
        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        //last方法，可以拼接sql语句
        wrapper.last( "limit 2" );
        List<CrmBanner> list = baseMapper.selectList( wrapper );
        return list;
    }
}
